home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 187 < prev    next >
Encoding:
Text File  |  1996-08-06  |  2.5 KB  |  59 lines

  1. Path: engnews1.Eng.Sun.COM!taumet!clamage
  2. From: kanze@gabi.gabi-soft.fr (J. Kanze)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: basic_string<T>::npos
  5. Date: 28 Jan 1996 17:03:04 GMT
  6. Organization: GABI Software, Sarl.
  7. Approved: clamage@eng.sun.com (comp.std.c++)
  8. Message-ID: <KANZE.96Jan28160100@gabi.gabi-soft.fr>
  9. References: <4e8r8a$9ir@bmtlh10.bnr.ca>
  10. NNTP-Posting-Host: taumet.eng.sun.com
  11. Content-Type: text
  12. X-Nntp-Posting-Host: gabi.gabi-soft.fr
  13. In-Reply-To: "john's message of 26 Jan 96 05:06:06 GMT
  14. Content-Length: 1775
  15. Originator: clamage@taumet
  16.  
  17. In article <4e8r8a$9ir@bmtlh10.bnr.ca> "john (j.d.) hickin"
  18. <hickin@bnr.ca> writes:
  19.  
  20. > From the October draft (I think); the basic_string class interface has these
  21. > declarations:
  22. >    typedef typename Allocator::size_type       size_type;
  23. >    ...
  24. >    static const size_type npos = -1;
  25. > It is my understanding that the Allocater::size_type should be an unsigned
  26. > flavour.  If this is indeed the case, are we to interpret nops as having the
  27. > value (size_type)(-1) ?
  28.  
  29. Yes.  And the various definitions of arithmetic on unsigned types means
  30. that in fact, this must be the largest value that the given unsigned
  31. type can contain.
  32.  
  33. At least, the above is true for the built-in unsigned types.  I'm
  34. intreged by the idea that size_type could conceivably be a user defined
  35. type.  In particular, consider an extensible unsigned type, conceptually
  36. unbound (and in reality only bound by available memory).  Presumably, it
  37. will have a constructor for unsigned; the compiler will convert -1 to
  38. (unsigned)(-1); on a 16 bit machine, 65536.  If the purpose of using
  39. this special type is precisely to obtain the extended range, we have a
  40. problem.
  41.  
  42. I suspect that the requirement should be: size_type must be an unsigned
  43. type with a conversion from int for which -1 results in the largest
  44. possible value.  An extensible unsigned type, as above, would require a
  45. constructor which takes an int (as well as the one with unsigned), and
  46. handle -1 by converting to some sort of special `infinity'.
  47. -- 
  48. James Kanze           (+33) 88 14 49 00          email: kanze@gabi-soft.fr
  49. GABI Software, Sarl., 8 rue des Francs Bourgeois, 67000 Strasbourg, France
  50. Conseils, Θtudes et rΘalisations en logiciel orientΘ objet --
  51.               -- A la recherche d'une activitΘ dans une region francophone
  52.  
  53. [ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  54.   Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  55.   is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
  56.  
  57.